// FastString.cpp: implementation of the FastString class.
//
//////////////////////////////////////////////////////////////////////
 
#include <string.h>
#include "FastString.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction

FastString::FastString(const char * psz)
:m_iSize(strlen(psz)),m_pData(new char[m_iSize+1]),m_iPTRNumbers(0)
{

}
FastString::~FastString()
{
	delete [] m_pData;
}

void FastString::DuplicatePointer(void)
{
	++m_iPTRNumbers;
}

void FastString::DestoryPointer(void)
{
	if (--m_iPTRNumbers == 0)
	{
		delete this;
	}
} 
	
void*	FastString::Dynamic_Cast(const char * pszType)
{
	void * pResult = NULL;
	if (strcmp(pszType,"IFastString") == 0)
	{
		pResult =  static_cast<IFastString*>(this);
	}
	else if (strcmp(pszType,"IPersistentObject") == 0)
	{
		pResult = static_cast<IPersistentObject*>(this);
	}
	else if (strcmp(pszType,"IExtensibleObject") == 0)
	{
		pResult = static_cast<IFastString*>(this);
	}
	else 
	{
		return NULL;
	}

	((IExtensibleObject *)pResult)->DuplicatePointer();
	return pResult;
}


int		FastString::Length(void)
{
	return m_iSize;
} 

int	FastString::Find(const char *psz)const
{
	return 0;
}

int	FastString::Load(const char* pszFileName)
{
	return 0;
}

int	FastString::Save(const char* pszFileName)
{
	return 0;
}

IFastString * CreateFastString(const char* psz)
{
	IFastString * pRt = new FastString(psz);
	if (pRt)
	{
		pRt->DuplicatePointer();
	}
	return pRt;
}
